<?php
/**
 * Zhub - A PHP Framework For API Developer
 *
 * This file is part of the Zhub package.
 *
 * (c) YiLong Fan <fantiq@163.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @author fanyilong <fantiq@163.com>
 * @copyright 2017 fanyilong. All rights reserved.
 * @package Zhub
 * @date 18-3-6
 */

namespace Zhub\DataBase\Tables;


abstract class Table
{
    abstract public static function initialize():array ;

    abstract public static function tableName():string ;

    abstract public static function prefix():string ;

    public static function fields(string ...$fields):array
    {
        $list = [];
        $property = static::initialize();
        foreach ($fields as $field) {
            if (!array_key_exists($field, $property)) {
                throw new \Exception();
            }
            $list[] = $property[$field];
        }
        return $list;
    }

    public function __toString():string
    {
        return static::tableName();
    }
}